package org.anyin.gitee.shiro.controller;

import org.anyin.gitee.shiro.base.Response;
import org.anyin.gitee.shiro.controller.form.LoginForm;
import org.anyin.gitee.shiro.service.ILoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping
public class LoginController {

    @Autowired
    private ILoginService loginService;

    @PostMapping("/login")
    public Response<String> login(@RequestBody LoginForm form){
        String token = loginService.login(form.getUsername(), form.getPassword());
        return new Response<>(token);
    }

    @PostMapping("/logout")
    public Response<String> logout(){
        return new Response<>();
    }
}
